<template>
  <view style="padding-top: 100px">
    <view class="heater">
      <button class="dindangli" @tap="gotoNoticeList">订单中心</button>
      <button class="dindangli" @tap="gotoOrderStatistics">订单统计</button>
    </view>
    <view>
      <view class="notice-section">
        <view class="section-header">
          <view class="section-title">通知消息 <i class="iconfont icon-&#xe7ab;"></i> </view>
          <!-- <view class="section-more" @tap="goToNoticeList">更多</view> -->
        </view>
        <NoticeList />
      </view>
    </view>

    <view class="tuichu">
      <button @tap="onLogout">退出登录</button>
    </view>
  </view>
</template>

<script setup>
import NoticeList from '@/components/NoticeList.vue'

import { useMemberStore } from '@/stores'

const memberStore = useMemberStore()
// 退出登录
const onLogout = () => {
  // 模态弹窗
  uni.showModal({
    content: '是否退出登录？',
    confirmColor: '#27BA9B',
    success: (res) => {
      if (res.confirm) {
        // 清理用户信息
        memberStore.clearProfile()
        // 返回登录页
        uni.reLaunch({ url: '/pages/login/login' })
        uni.hideHomeButton()
      }
    },
  })
}

const gotoNoticeList = () => {
  uni.navigateTo({
    url: '/pagesOrder/list/list?type=1',
  })
}

const gotoOrderStatistics = () => {
  uni.navigateTo({
    url: '/pagesMember/orderStatistics/orderStatistics',
  })
}
</script>

<style scoped>
.tuichu {
  margin-top: 100px;
}
.heater {
  display: flex;
  justify-content: space-around;
  margin-top: 10px;
}

.dindangli {
  width: 200rpx;
  display: inline-block;
  background-color: #22b91a;
}

.section-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30rpx;
  margin-bottom: 20rpx;
}

.notice-section {
  margin: 20rpx 30rpx;
  background-color: #fff;
  border-radius: 24rpx;
  padding: 30rpx 0;
  box-shadow: 0 5rpx 20rpx rgba(0, 0, 0, 0.05);
}
</style>
